<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
</head>
<style type="text/css">
    .center{
        position: relative;
        top: 300px;
        width: 600px;
        margin: 0px auto;
    }
</style>
<body>
<div class="center">
    <form class="layui-form admininfo"  action="" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">账&nbsp&nbsp&nbsp&nbsp户：</label>
            <div class="layui-input-inline">
                <input type="text" name="username" id="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密&nbsp&nbsp&nbsp&nbsp码：</label>
            <div class="layui-input-inline">
                <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input  type="button" class="layui-btn submit" value="登录">
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>
</div>
<script type="text/javascript" src="layui/layui.all.js"></script>
<script type="text/javascript">
    var $ = layui.jquery;
    var layer = layui.layer;
    $(".submit").click(function () {
        $.ajax({
            url:"/login.action",
            type:"POST",
            data:$(".admininfo").serialize(),
            dataType:"json"
        }).done(function (data) {
            if(data.code==0){
                window.location.href ="index1.html";
            }else {
                layer.msg("账户或密码错误！");
            }
        }).fail(function () {
            layer.msg("账户或密码错误！");
        })
    })
</script>
</body>
</html>